home *** CD-ROM | disk | FTP | other *** search
/ United Public Domain Gold 4 / United Public Domain Gold 4.iso / scope / sc066.dms / sc066.adf / PBG / PBG.asm < prev    next >
Assembly Source File  |  1989-03-11  |  4KB  |  144 lines

  1.  
  2.  
  3.  
  4.                 include     "exec/types.i"
  5.                 include     "exec/ports.i"
  6.                 include     "exec/nodes.i"
  7.                 include     "exec/memory.i"
  8.                 include     "exec/io.i"
  9.                 include     "exec/tasks.i"
  10.                 include     "exec/interrupts.i"
  11.                 include     "devices/input.i"
  12.                 include     "exec/devices.i"
  13.                 include     "devices/inputevent.i"
  14.  
  15.  
  16.                 XREF        _AbsExecBase
  17.                 XREF        _LVODoIO
  18.                 XREF        _LVOOpenDevice
  19.                 XREF        _LVOCreateStdIO
  20.                 XREF        _LVOAllocSignal
  21.                 XREF        _LVOFindTask
  22.                 XREF        _LVOForbid
  23.                 XREF        _LVOPermit
  24.                 XREF        _LVOWait
  25.  
  26.                 move.l      #MyInterrupt,a0
  27.                 move.l      #MyData,IS_DATA(a0)
  28.                 move.l      #MyCode,IS_CODE(a0)
  29.                 move.b      #51,LN_PRI(a0)
  30.  
  31.                 move.l      #MyMsgPort,a0
  32.                 move.b      #NT_MSGPORT,LN_TYPE(a0)
  33.  
  34.                 movea.l     _AbsExecBase,a6
  35.                 move.l      #0,a1
  36.                 jsr         _LVOFindTask(a6)
  37.                 move.l      d0,MyTask
  38.  
  39.                 movea.l     _AbsExecBase,a6
  40.                 move.l      #-1,d0
  41.                 jsr         _LVOAllocSignal(a6)
  42.                 move.l      d0,MySigBit
  43.  
  44.                 move.l      #MyMsgPort,a0
  45.                 move.l      MyTask,MP_SIGTASK(a0)
  46.                 move.b      MySigBit,MP_SIGBIT(a0)
  47.                 move.b      #PA_SIGNAL,MP_FLAGS(a0)
  48.  
  49.                 move.l      #MyIOStdReq,a0
  50.                 move.l      #MyMsgPort,MN_REPLYPORT(a0)
  51.                 move.b      #NT_MESSAGE,LN_TYPE(a0)
  52.  
  53.                 movea.l     _AbsExecBase,a6
  54.                 move.l      #DevName,a0
  55.                 move.l      #0,d0
  56.                 move.l      #MyIOStdReq,a1
  57.                 move.l      #0,d1
  58.                 jsr         _LVOOpenDevice(a6)
  59.                 tst.l       d0
  60.                 bne         Abort
  61.  
  62.  
  63.                 move.l      #MyIOStdReq,a0
  64.                 move.w      #IND_ADDHANDLER,IO_COMMAND(a0)
  65.                 move.l      #MyInterrupt,IO_DATA(a0)
  66.  
  67.                 movea.l     _AbsExecBase,a6
  68.                 move.l      #MyIOStdReq,a1
  69.                 jsr         _LVODoIO(a6)
  70.                 tst.l       d0
  71.                 bne         Abort
  72.  
  73. Loop:
  74.                 move.l      _AbsExecBase,a6
  75.                 move.l      #$00,d0
  76.                 jsr         _LVOWait(a6)   ;permanent wait
  77.                 bra         Loop           ;just in case....
  78. MyCode:
  79.                 move.l      a0,EV
  80.  
  81.                 movea.l     _AbsExecBase,a6
  82.                 jsr         _LVOForbid(a6)
  83.  
  84.                 cmpi.b      #IECLASS_RAWMOUSE,ie_Class(a0)
  85.                 bne         EndHandler
  86.  
  87.                 tst.w       SpriteFlg
  88.                 beq         SkipClear
  89.  
  90. VertBlank:
  91.                 move.w      $dff01e,d0
  92.                 andi.w      #$0020,d0
  93.                 beq         VertBlank
  94.  
  95.                 move.w      #$8020,$dff096 ;enable sprite DMA
  96.                 clr.l       Timer
  97.                 clr.w       SpriteFlg
  98.                 bra         SkipClear
  99.  
  100. EndHandler:
  101.                 cmpi.l      #100,Timer
  102.                 beq         SkipClear
  103.                 addi.l      #1,Timer
  104.                 cmpi.l      #100,Timer
  105.                 bne         SkipClear
  106.  
  107.                 move.w      #1,SpriteFlg
  108. VertBlank2:
  109.                 move.w      $dff01e,d0
  110.                 andi.w      #$0020,d0
  111.                 beq         VertBlank2
  112.  
  113.                 move.w      #$0020,$dff096     ;disable sprite dma
  114.  
  115. SkipClear:
  116.                 movea.l     _AbsExecBase,a6
  117.                 jsr         _LVOPermit(a6)
  118.                 move.l      EV,a0
  119.                 move.l      EV,d0
  120.                 rts
  121. Abort:
  122.                 clr.l       d0
  123.                 rts
  124.  
  125.  
  126.  
  127. MyInterrupt:    dcb.b       IS_SIZE,0
  128. MyInputEvent:   dcb.b       ie_SIZEOF,0
  129. MyIOStdReq:     dcb.b       IOSTD_SIZE,0
  130. MyMsgPort:      dcb.b       MP_SIZE,0
  131. MyMessage:      dcb.b       MN_SIZE,0
  132. MyData:         ds.l        512
  133.  
  134.  
  135. DevName:        dc.b        'input.device',0
  136.                 cnop        0,2
  137.  
  138. EV              ds.l        1
  139. MyTask          ds.l        1
  140. MySigBit        ds.l        1
  141.  
  142. Timer           ds.l        1
  143. SpriteFlg       ds.w        1
  144.